<HTML><HEAD><TITLE>at_eof(+Stream)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Stream I/O</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>at_eof(+Stream)</H1>
Succeeds if the stream Stream is positioned at end of file.


<DL>
<DT><EM>Stream</EM></DT>
<DD>Integer (stream number) or Atom (reserved or user-defined symbolic stream name).
</DD>
</DL>
<H2>Description</H2>
   Used to test if the input stream Stream is positioned at end of file.
<UL><LI>
   For file streams and string streams, this means that either the next read
   operation will return an end-of-file condition, or end-of-file was already
   read and the next read operation would result in a past-end-of-file error.
</LI><LI>
   For tty streams, it means only that there is currently no further input
   available, and a subsequent read operation will prompt for more.
</LI><LI>
   For queue streams, it means only that the queue is currently empty.
   The queue will recover from the end-of-file condition when new data
   is written into it from the write end.
</LI><LI>
   For pipe and socket streams, this condition means that the next read
   operation will either block or return an end-of-file condition.
   To check whether there is any data to read, use select/3.
</LI><LI>
   The null stream is always at end-of-file.
</LI></UL>
   Stream can be a symbolic stream name or a physical stream number.

<H3>Modes and Determinism</H3><UL>
<LI>at_eof(+) is semidet
</UL>
<H3>Fail Conditions</H3>
Fails if Stream is a file with its pointer not at end of file.
<H3>Exceptions</H3>
<DL>
<DT><EM>(4) instantiation fault </EM>
<DD>Stream is not instantiated.
<DT><EM>(5) type error </EM>
<DD>Stream is instantiated, but not to an atom or an integer.
<DT><EM>(192) illegal stream mode </EM>
<DD>Stream is an illegal stream mode.
</DL>
<H2>Examples</H2>
<PRE>
Success:
      at_eof(null).

      [eclipse]: open(file1,update,s), at_eof(s),
	  write(s,hello), at(s,5), at_eof(s), close(s).
      yes.

Fail:

      [eclipse]: open(file1,write,s),write(s,hello), close(s),
	  open(file1,read,s), at_eof(s), close(s).
      no.

Error:
      at_eof(X).                  (Error 4).
      at_eof("s").                (Error 5).
      at_eof(not_a_stream).       (Error 192).



</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/iostream/at-2.html">at / 2</A>, <A HREF="../../kernel/iostream/seek-2.html">seek / 2</A>, <A HREF="../../kernel/iostream/stream_truncate-1.html">stream_truncate / 1</A>
</BODY></HTML>
